package com.foyekoo.project001.utils;

import android.content.Context;
import android.media.AudioManager;
import android.media.SoundPool;
import android.util.Log;

import com.foyekoo.project001.R;

public class MusicPlayFactory {
    private static MusicPlayFactory instance;
    private static SoundPool soundPool;

    public static MusicPlayFactory getInstance(){
        if (instance == null) {
            instance = new MusicPlayFactory();
            soundPool  = new SoundPool(1, AudioManager.STREAM_MUSIC, 0);
        }
        return instance;
    }

    private MusicPlayFactory(){


    }




    public String getPlayMusicStr(byte command, Context activity){
        String str = "";
        switch(command) {
            case 0x01:
                musicId = R.raw.music_01;
                break;
            case 0x02:
                musicId = R.raw.music_02;
                break;
            case 0x03:
                musicId = R.raw.music_03;
                break;
            case 0x04:
                musicId = R.raw.music_04;
                break;
            case 0x05:
                musicId = R.raw.music_05;
                break;
            case 0x06:
                musicId = R.raw.music_06;
                //TODO
                break;
            case 0x07:
                musicId = R.raw.music_07;
                str = "快来推我嘛~~";
                break;
            case 0x08:
                musicId = R.raw.music_08;
                str = "快来体验一下推的感觉吧~";
                break;
            case 0x10://10
                musicId = R.raw.music_10;
                str = "用头脑而不是蛮力哟~";
                break;
            case 0x0a://11
                musicId = R.raw.music_11;
                str = "来一局！送你百发百中哦~";
                break;
            case 0x0b://12
                musicId = R.raw.music_12;
                str = "很好！你已经成功吸引了我的注意~";
                break;
            case 0x0c://13
                musicId = R.raw.music_13;
                str = "嘿嘿~投个币~我们的故事就开始了~~";
                break;
            case 0x0d://14
                musicId = R.raw.music_14;
                str = "掌握技巧，搬空礼品!";
                break;
            case 0x0e://15
                musicId = R.raw.music_15;
                str = "推推达人！";
                break;
            case 0x0f://16
                musicId = R.raw.music_16;
                str = "来展示你高端的操作吧！";
                break;
            case 0x11://17
                // musicId = R.raw.music_18;
                str = "来~开始你的表演吧!";
                break;
            case 0x12://18
                musicId = R.raw.music_18;
                str = "看准位置，搬空礼品！";
            case 0x13://19
                musicId = R.raw.music_19;
                str = "哇！！！恭喜你中奖了！！";
                break;
        }
        return str;
    }



    private int musicId;
    public String playMusic(byte command, Context activity){
        Log.d("MusicePlay","-->" + command);
        String str = "";
        switch(command) {
            case 0x01:
                musicId = R.raw.music_01;
                break;
            case 0x02:
                musicId = R.raw.music_02;
                break;
            case 0x03:
                musicId = R.raw.music_03;
                break;
            case 0x04:
                musicId = R.raw.music_04;
                break;
            case 0x05:
                musicId = R.raw.music_05;
                break;
            case 0x06:
                musicId = R.raw.music_06;
                //TODO
                break;
            case 0x07:
                musicId = R.raw.music_07;
                str = "快来推我嘛~~";
                break;
            case 0x08:
                musicId = R.raw.music_08;
                str = "快来体验一下推的感觉吧~";
                break;
            case 0x10://10
                musicId = R.raw.music_10;
                str = "用头脑而不是蛮力哟~";
                break;
            case 0x0a://11
                musicId = R.raw.music_11;
                str = "来一局！送你百发百中哦~";
                break;
            case 0x0b://12
                musicId = R.raw.music_12;
                str = "很好！你已经成功吸引了我的注意~";
                break;
            case 0x0c://13
                musicId = R.raw.music_13;
                str = "嘿嘿~投个币~我们的故事就开始了~~";
                break;
            case 0x0d://14
                musicId = R.raw.music_14;
                str = "掌握技巧，搬空礼品!";
                break;
            case 0x0e://15
                musicId = R.raw.music_15;
                str = "推推达人！";
                break;
            case 0x0f://16
                musicId = R.raw.music_16;
                str = "来展示你高端的操作吧！";
                break;
            case 0x11://17
               // musicId = R.raw.music_18;
                str = "来~开始你的表演吧!";
                break;
            case 0x12://18
                musicId = R.raw.music_18;
                str = "看准位置，搬空礼品！";
            case 0x13://19
                musicId = R.raw.music_19;
                str = "哇！！！恭喜你中奖了！！";
                break;
        }

        PlayMusicTool.getInstance().playMusicToId(activity,musicId);
        return str;

    }
}
